part of native_dio_adapter;

/// An implementation of [NativeDioAdapterPlatform] that uses method channels.
class MethodChannelNativeDioAdapter extends NativeDioAdapterPlatform {
  /// The method channel used to interact with the native platform.
  @visibleForTesting
  final methodChannel = const MethodChannel('native_dio_adapter');

  @override
  Future<Result?> sendRequest({required NativeRequestOptions request}) async {
    final result =
        await methodChannel.invokeMethod('sendRequest', request.encode());
    if (result == null) return null;
    final map = result.map((key, value) {
      return MapEntry(key.toString(), value);
    });
    return Result.decode(Map<String, dynamic>.from(map));
  }
}
